#include <iostream>

#include "MyCoroutine.h"


MyCoroutine<int> func(int start, int end)
{
    std::cout << "begin cal, start: " << start << ", end: " << end << std::endl;
    int result = 0;
    for (int i = start; i <= end; ++i)
    {
        result += i;
        co_yield result;
    }

    co_return result;
}

void test() {
    auto co = func(1, 10);

    int count = 0;
    while (!co.Done())
    {
        std::cout << "count: " << ++count << ", result: " << co.GetValue() << std::endl;
        co.Resume();
    }

    std::cout << "result: " << co.GetValue() << std::endl;
}

int main() 
{
    test();
    return 0;
}